package com.reflex;

import com.reflex.annotations.AutoRunMethod;

import java.lang.reflect.Method;

public class ReflexDemo10 {
    public static void main(String[] args) throws Exception {
        Class<?> aClass = Class.forName("com.reflex.Person");
        Object object = aClass.newInstance();
        //Method sayHello = aClass.getDeclaredMethod("sayHello");
        Method[] declaredMethods = aClass.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            boolean make = declaredMethod.isAnnotationPresent(AutoRunMethod.class);
            if (make){
                System.out.println("有注解");
                declaredMethod.invoke(object);
            }else {
                System.out.println("没有注解");
            }
        }


//        Method declaredMethod = aClass.getDeclaredMethod("watchTVs");
//        boolean annotationPresent = declaredMethod.isAnnotationPresent(AutoRunMethod.class);
//        if (annotationPresent){
//            System.out.println("有注解");
//        }else {
//            System.out.println("没有注解");
//        }



    }
}
